package com.study.es.Item.controller;

import com.study.es.Item.document.Item;
import com.study.es.Item.service.EsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/es")
public class EsController {

    @Autowired
    private EsService esService;

    @GetMapping("/createIndex")
    public String createIndex(){
        esService.createIndex();
        return "ok";
    }

    @GetMapping("/deleteIndex")
    public String deleteIndex(){
        esService.deleteIndex();
        return "ok";
    }

    @GetMapping("/add")
    public String add(){
        esService.add();
        return "ok";
    }

    @GetMapping("/delete/{id}")
    public String delete(@PathVariable Long id){
        esService.delete(id);
        return "ok";
    }

    @GetMapping("/update")
    public String update(){
        esService.update();
        return "ok";
    }
    @GetMapping("/select/{id}")
    public Item select(@PathVariable Long id){
        Item select = esService.select(id);
        return select;
    }
}
